<template>
  <el-dialog title="详情"
             :close-on-click-modal="false" append-to-body
             :visible.sync="visible" class="jsbos-dialog jsbos-dialog_center" lock-scroll
             width="600px">
    <el-row :gutter="15" class="">
      <el-form ref="elForm" :model="dataForm" size="small"
               label-width="100px" label-position="right">
        <template v-if="!loading">
          <el-col :span="24">
            <el-form-item label="作业内容"
                          prop="description">
              <p>{{ dataForm.description }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="附件"
                          prop="attachments">
              <UploadFz v-model="dataForm.attachments"
                        disabled
                        detailed :fileSize="50" sizeUnit="MB" :limit="5" buttonText="点击上传"
              </UploadFz>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="有效标志"
                          prop="enabledMark">
              <p>{{ dataForm.enabledMark | dynamicText(enabledMarkOptions) }} </p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="创建用户"
                          prop="creatorUserId">
              <p>{{ dataForm.creatorUserId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="创建时间"
                          prop="creatorTime">
              <p>{{ dataForm.creatorTime }}</p>
            </el-form-item>
          </el-col>
        </template>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">          取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
import request from '@/utils/request'
import PrintBrowse from '@/components/print-browse'
import jsbos from '@/utils/jsbos'

export default {
  components: {PrintBrowse},
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      printBrowseVisible: false,
      printId: '',
      dataForm: {
        id: '',
        homeworkId: '',
        courseId: '',
        description: '',
        attachments: [],
        enabledMark: "",
        creatorUserId: "",
        creatorTime: "",
      },
      enabledMarkOptions: [{"fullName": "未提交", "id": "0"}, {"fullName": "已提交", "id": "1"}, {
        "fullName": "已批阅",
        "id": "2"
      }],

    }
  },
  computed: {},
  watch: {},
  created() {

  },
  mounted() {
  },
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll
      _dataAll.attachments = _dataAll.attachments ? JSON.parse(_dataAll.attachments) : []
      this.dataForm = _dataAll
    },

    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true
          request({
            url: '/api/course/TemsCourseStudyHomework/detail/' + this.dataForm.id,
            method: 'get'
          }).then(res => {
            this.dataInfo(res.data)
            this.loading = false
          })
        }

      })
    },
  },
}

</script>
